<template>
	<div >
		<div class="first-mask" v-show="isFirstTimeIn"><p style="margin-bottom:3rem">正在进入微商城...</p></div>
		<yd-actionsheet :items="serviceItems" v-model="isShow" cancel="取消" class="kefu-layout"></yd-actionsheet>
		<a href="javascript:void(0)" class="kefu" @click="isShow=!isShow"><i class="iconfont icon-htmal5icon31"></i></a>
	</div>
</template>

<script>
export default {
	name: 'customService',
	data () {
		return {
            isFirstTimeIn:true,
			params:{
                CommunityShopId:23
            },
			isShow:false,
			serviceItems: [
				{
					label: '',
				},
			]
		}
	},
	mounted(){
		// var search = location.search;
        // var obj={};
        // if(search.indexOf('?')>-1){
        //     var arr=search.substr(1).split('&');
        //     arr.forEach(function(item){
        //         item=item.split('=');
        //         obj[item[0]]=item[1];
        //     })
        // }
		// this.params=obj;
		this.getKeFu();
	},
	watch:{
		isShow(){
			this.$emit('getShow',this.isShow);
		}
	},
	methods:{
		getKeFu:function(){
			this.http.get('/Distributor/GetCommunityShopH5?CommunityShopId='+this.params.CommunityShopId)
			.then(res=>{
				if(res.data.isSuccess){
					let kefuList=res.data.objects[0];
					if(!kefuList.isEnabled){
						this.$dialog.loading.close();
						this.$router.replace({name:"404"})
					}
					this.isFirstTimeIn=false
					this.serviceItems[0].label=`${kefuList.shopName} - ${kefuList.address}`
					kefuList.communityShopSalesConsultants.forEach(item => {
						let obj={
							label:`${item.name} - ${item.mobilePhone}`,
							callback: () => {
								location.href=`tel:${item.mobilePhone}`
							}
						}
						this.serviceItems.push(obj)
					});
				}else{
					this.$dialog.toast({mes:res.data.message, icon:'none', timeout:2000});
				}
			})
		},
	}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
	.first-mask{
        position: fixed;
        display: flex;
        align-items: center;
        justify-content: center;
        left: 0;
        top: 0;
        width:100%;
        height: 100%;
        line-height: 100%;
        text-align: center;
        background-color: #fff;
        font-size: .35rem;
        z-index: 1999;
    }
</style>
